using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace ArchSoft
{
    public partial class ViewImage : Form
    {
        Image Img = null;
        const int Img2Bound = 26; //1mm cho bound!
        const int Bound2Out = 10;
        public ViewImage(Image img)
        {
            InitializeComponent();
            Img = img;
        }

        private void ViewImage_Load(object sender, EventArgs e)
        {            
            if (Img != null)
            {
                int Wid = Img.Width + 36*2;
                int Hgt = Img.Height + 36*2;
                this.Pnl_Out.Width = Wid;
                this.Pnl_Out.Height = Hgt;
                this.Pnl_Bound.Height = Hgt - 20;
                this.Pnl_Bound.Width = Wid - 20;
                this.pictureBox1.Width = Img.Width;
                this.pictureBox1.Height = Img.Height;
                this.pictureBox1.Image = Img;

                this.Width += Wid - 894; //894, 518
                this.Height += Hgt - 518;

                this.Left -= (Wid - 894)/2;
                this.Top -= (Hgt - 518) / 2;

                if (Wid >= Screen.PrimaryScreen.Bounds.Width - 5)
                {
                    this.Width = Screen.PrimaryScreen.Bounds.Width;
                    this.Left = 0;
                }
                if (Hgt >= Screen.PrimaryScreen.Bounds.Height - 20)
                {
                    this.Top = 0;
                    this.Height = Screen.PrimaryScreen.Bounds.Height;
                }
               
            }
        }
    }
}